import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:introduction_screen/introduction_screen.dart';

class introDemo extends StatefulWidget {
  const introDemo({super.key});

  @override
  State<introDemo> createState() => _introDemoState();
}

List<PageViewModel> listPagesViewModel = [
  PageViewModel(
    title: "Title of introduction page",
    body: "Welcome to the app! This is a description of how it works.",
    image: const Center(
      child: Icon(Icons.waving_hand, size: 50.0),
    ),
  ),
  PageViewModel(
      title: "这是带页脚的",
      body: "Welcome to the app! This is a description of how it works.",
      image: const Center(
        child: Icon(Icons.home_filled, size: 50.0),
      ),
      footer: ElevatedButton(
        onPressed: () {
          // On button pressed
        },
        child: const Text("Let's Go!"),
      )),
  PageViewModel(
    title: "这是自定义样式的",
    body:
        "This is a description on a page with an orange title and bold, big body.",
    image: const Center(
      child: Text("👋", style: TextStyle(fontSize: 100.0)),
    ),
    decoration: const PageDecoration(
      titleTextStyle: TextStyle(color: Colors.orange),
      bodyTextStyle: TextStyle(fontWeight: FontWeight.w700, fontSize: 20.0),
    ),
  ),
  PageViewModel(
    title: "Title of custom body page",
    bodyWidget: Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: const [
        Text("Click on "),
        Icon(Icons.edit),
        Text(" to edit a post"),
      ],
    ),
    image: const Center(child: Icon(Icons.android)),
  )
];

class _introDemoState extends State<introDemo> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('测试展示页面')),
      body: IntroductionScreen(
        pages: listPagesViewModel,
        showNextButton: false,
        showBackButton: true,
        skip: const Text("Skip"),
        back: const Icon(Icons.arrow_back),
        done: const Text("Done"),
        onDone: () {
          // On button pressed
          Get.toNamed('/');
        },
      ),
    );
  }
}
